package main.java.chessfootball.rules.checker;

import main.java.chessfootball.model.game.Field;

/**
 * User: Igor
 * Date: 27.07.2011
 * Time: 7:02:33
 */
public class PlayerAreaChecker extends AbstractPutChecker
{

	@Override
	public boolean valid()
	{
		if (Field.PLAY_AREA.contains(put.getCell()))
		{
			return true;
		}
		if (!Field.GAME_AREA.contains(put.getCell()))
		{
			return false;
		}
		if (game.getRule().getGame().isGoalkeeper())
		{
			if (put.getPlayer() == 1)
			{
				if (Field.GOALS_AREA[game.getField().getTeam(put.getSide()).getHalf().getId()].contains(put.getCell()))
				{
					return true;
				}
			}
		}
		if (Field.GOALS_AREA[0].contains(put.getCell()))
		{
			return false;
		}
		if (Field.GOALS_AREA[1].contains(put.getCell()))
		{
			return false;
		}
		return true;
	}
}
